﻿using System;
using System.Windows.Forms;

namespace Voize
{
    internal partial class fMixer : Form
    {
        internal fMixer()
        {
            InitializeComponent();
        }

        private CSound m_CurrentSound;
        private IrrKlang.ISound m_SoundHandler;

        internal void SetConnection(IrrKlang.ISound sound_handler)
        {
            m_SoundHandler = sound_handler;
            CSound sound_connection = new CSound(sound_handler);
            m_CurrentSound = sound_connection;
        }

        private void trackPan_Scroll(object sender, EventArgs e)
        {
            if (m_SoundHandler != null)
            {
                m_CurrentSound.SetPan(trackPan.Value);
                Mixer.CurrentPan = (float)trackPan.Value / (float)10;
            }
        }

        private void trackSpeed_Scroll(object sender, EventArgs e)
        {
            if (m_SoundHandler != null)
            {
                m_CurrentSound.SetPlayingSpeed(trackSpeed.Value);
                Mixer.CurrentPlayingSpeed = (float)trackSpeed.Value / (float)10;
            }
        }

        private void fMixer_Load(object sender, EventArgs e)
        {
            if (m_SoundHandler != null)
            {
                trackPan.Value = (int)m_CurrentSound.CurrentPanValue * 10;
                trackSpeed.Value = (int)m_CurrentSound.CurrentPlaybackSpeed * 10;
            }
        }
    }
}
